package com.pda.xinmazhi.presenter;


import com.pda.xinmazhi.bean.LatheMachinBean;
import com.pda.xinmazhi.bean.LatheOrderBean;
import com.pda.xinmazhi.contract.MachineCallContract;
import com.pda.xinmazhi.net.NetUtils;
import com.wangshen.base.net.bean.BaseAppEntity;
import com.wangshen.base.ui.mvp.base.presenter.BasePresenter;

import java.util.List;

import io.reactivex.functions.Consumer;

public class MachineCallPresenter extends BasePresenter<MachineCallContract.View> implements MachineCallContract.Presenter {
    @Override
    public void getCenterByUserId() {
       /* NetUtils.geApi().getCenterByUserId()
                .compose(this.handleEverythingResult())
                .subscribe(new Consumer<BaseAppEntity<List<WorkSurfaceBean>>>() {
                    @Override
                    public void accept(BaseAppEntity<List<WorkSurfaceBean>> listBaseAppEntity) throws Exception {
                        getView().setFaceList(listBaseAppEntity.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        getView().showMessage(throwable.getMessage());
                    }
                });*/
    }

    @Override
    public void getLatheListByCenter(String centerCode) {
        NetUtils.geApi().getLatheListByCenter(centerCode)
                .compose(this.handleEverythingResult())
                .subscribe(new Consumer<BaseAppEntity<List<LatheMachinBean>>>() {
                    @Override
                    public void accept(BaseAppEntity<List<LatheMachinBean>> listBaseAppEntity) throws Exception {
                        getView().setLatheList(listBaseAppEntity.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        getView().showMessage(throwable.getMessage());
                    }
                });
    }

    @Override
    public void getOrderListByLathe(String latheCode) {
        NetUtils.geApi().getOrderListByLathe(latheCode,"")
                .compose(this.handleEverythingResult())
                .subscribe(new Consumer<BaseAppEntity<List<LatheOrderBean>>>() {
                    @Override
                    public void accept(BaseAppEntity<List<LatheOrderBean>> listBaseAppEntity) throws Exception {
                        if (listBaseAppEntity.getData().size() == 0){
                            getView().showMessage("未查询到数据！");
                            return;
                        }
                        getView().setDataList(listBaseAppEntity.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        getView().showMessage(throwable.getMessage());
                    }
                });
    }
    @Override
    public void getOrderSearchListByLathe(String latheCode, String proOrderNo) {
        /*NetUtils.geApi().getOrderListByLathe(latheCode,proOrderNo)
                .compose(this.handleEverythingResult())
                .subscribe(new Consumer<BaseAppEntity<List<LatheOrderBean>>>() {
                    @Override
                    public void accept(BaseAppEntity<List<LatheOrderBean>> listBaseAppEntity) throws Exception {
                        if (listBaseAppEntity.getData().size() == 0){
                            getView().showMessage("未查询到数据！");
                            return;
                        }
                        getView().setDataList(listBaseAppEntity.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        getView().showMessage(throwable.getMessage());
                    }
                });*/
    }
    @Override
    public void getOrderListByLathe(String latheCode, String proOrderNo) {
       /* NetUtils.geApi().getOrderListByLathe(latheCode,proOrderNo)
                .compose(this.handleEverythingResult())
                .subscribe(new Consumer<BaseAppEntity<List<LatheOrderBean>>>() {
                    @Override
                    public void accept(BaseAppEntity<List<LatheOrderBean>> listBaseAppEntity) throws Exception {
                        if (listBaseAppEntity.getData().size() == 0){
                            getView().showMessage("未查询到数据！");
                            return;
                        }
                        getView().setScanData(listBaseAppEntity.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        getView().showMessage(throwable.getMessage());
                    }
                });*/
    }

    @Override
    public void getAlreadyOrderListByLathe(String latheCode,String proOrderNo) {
        NetUtils.geApi().getAlreadyOrderListByLathe(latheCode,proOrderNo)
                .compose(this.handleEverythingResult())
                .subscribe(new Consumer<BaseAppEntity<List<LatheOrderBean>>>() {
                    @Override
                    public void accept(BaseAppEntity<List<LatheOrderBean>> listBaseAppEntity) throws Exception {
                        getView().setDataList(listBaseAppEntity.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        getView().showMessage(throwable.getMessage());
                    }
                });
    }
}
